import OpenAI from "openai";

// 在运行环境中读取github的token
const token = "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";//process.env['GITHUB_TOKEN']
const endpoint = "https://models.inference.ai.azure.com";
const modelName = "gpt-4o";

async function main() {
  const client = new OpenAI({ baseURL: endpoint, apiKey: token});

  const response = await client.chat.completions.create({
    model: modelName,
    temperature: 1.0,
    max_tokens: 1000,
    top_p: 1.0,
    messages: [
      {roel: 'system', content: '你是一个语文老师'},
      {role: 'user', content: '我小孩语文考试只考了60分，我要怎么提高他的成绩'}
    ]
  })

  console.log(response.choices[0].message.content);
  
}

main()